-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(libs): add automatic migration dir discovery #1673
Conversation
WalkthroughThe changes involve a significant update to the Changes
Sequence Diagram(s)sequenceDiagram
participant A as Application
participant B as Migrator
participant C as Migration Files
A->>B: Request to register migrations
B->>C: Collect migration files from embed.FS
C-->>B: Return list of migration files
B->>B: Execute each migration in transaction context
B-->>A: Confirm migrations registered
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
libs/go-libs/migrations/collect.go (1)
12-35
: LGTM!The code changes are approved.
Suggestions for improvement:
Add support for down migrations by adding a
DownWithContext
function to theMigration
struct. This will allow the user to roll back migrations if needed.Allow the user to specify the directory name instead of hardcoding it to "migrations". This will make the function more flexible and reusable.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- components/ledger/internal/storage/ledgerstore/bucket.go (2 hunks)
- libs/go-libs/migrations/collect.go (1 hunks)
Additional comments not posted (6)
components/ledger/internal/storage/ledgerstore/bucket.go (6)
6-6
: LGTM!The code change is approved.
9-10
: LGTM!The code change is approved.
18-19
: LGTM!The code change is approved.
81-85
: LGTM!The code change is approved.
87-135
: LGTM!The code change is approved.
137-137
: LGTM!The code change is approved.
11a96d1
to
96adbb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
libs/go-libs/migrations/collect.go (1)
12-35
: LGTM! Consider adding more comments to explain the function.The
CollectMigrationFiles
function looks good and follows best practices for error handling and executing SQL statements usingbun
. The code changes are approved.To improve the readability and maintainability of the code, consider adding more comments to explain the purpose and behavior of the function. For example:
// CollectMigrationFiles reads the contents of the "migrations" directory in the // provided embedded filesystem and returns a slice of Migration structs. // Each Migration struct contains the name of the migration file and a function // that executes the SQL migration using the provided bun.Tx transaction. func CollectMigrationFiles(fs embed.FS) ([]Migration, error) { // ... }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- components/ledger/internal/storage/ledgerstore/bucket.go (2 hunks)
- libs/go-libs/migrations/collect.go (1 hunks)
Additional comments not posted (4)
components/ledger/internal/storage/ledgerstore/bucket.go (4)
6-6
: LGTM!The code changes are approved.
9-10
: LGTM!The code changes are approved.
18-19
: LGTM!The code changes are approved.
81-137
: LGTM!The code changes are approved. The refactored
registerMigrations
function and the overriddeninitSchema
migration improve the maintainability and upgrade path of the migration system.
No description provided.